package sort.oj;

public class 剑指offer21 {
    public int[] exchange(int[] nums) {
        if(nums == null){
            return nums;
        }
        int length = nums.length;
        int left = 0;
        int right = length - 1;

        while (left < right){
            while (left < right && (nums[left] & 0x1) != 0){
                left ++;
            }
            while (left < right && (nums[right] & 0x1) == 0){
                right --;
            }
            if(left < right){
                int temp = nums[left];
                nums[left] = nums[right];
                nums[right] = temp;
            }
        }
        return nums;
    }
}
